{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $operation == 'display'} class="active" {/if}><a href="{php echo $this->createWebUrl('nav',array('op' =>'display'))}">导航列表</a></li>
	<li{if empty($adv['id']) && $operation == 'post'} class="active" {/if}><a href="{php echo $this->createWebUrl('nav',array('op' =>'post'))}">添加导航</a></li>
	{if !empty($_GPC['id']) &&  $operation == 'post'}<li  class="active"><a href="{php echo $this->createWebUrl('nav',array('op' =>'post','id'=>$_GPC['id']))}">编辑广告</a></li>{/if}
</ul>

{if $operation == 'display'}
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:30px;">ID</th>
					<th>显示顺序</th>	
					<th>图标</th>				
					<th>标题</th>
					<th>连接</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $adv}
				<tr>
					<td>{$adv['id']}</td>
					<td>{$adv['displayorder']}</td>
					<td><img src="{php echo tomedia($adv['icon'])}" style="width:80px;height:80px;border-radius:30px;"/></td>
					<td>{$adv['name']}</td>
					<td>{$adv['link']}</td>
					<td style="text-align:left;">
						<a href="{php echo $this->createWebUrl('nav', array('op' => 'post', 'id' => $adv['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('nav', array('op' => 'delete', 'id' => $adv['id']))}"class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
{elseif $operation == 'post'}

<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="{$adv['id']}" />
		<div class="panel panel-default">
			<div class="panel-heading">
				首页导航设置
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="displayorder" class="form-control" value="{$adv['displayorder']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>导航名称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='advname' name="name" class="form-control" value="{$adv['name']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">导航图标</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_image('icon', $adv['icon'])}
						
						<br>
						建议尺寸大小42*32px &nbsp;&nbsp;<a href="http://www.easyicon.net/" target="_black">去挑选一个好看的图标</a>
					</div>
				</div>
				 <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">导航连接</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_link('link',$adv['link'])}
						<br>
						站外链接请以http://开头
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='enabled' value=1' {if $adv['enabled']==1}checked{/if} /> 是
						</label>
						<label class='radio-inline'>
							<input type='radio' name='enabled' value=0' {if $adv['enabled']==0}checked{/if} /> 否
						</label>
					</div>
				</div>
			</div>
		</div>
<div class="form-group col-sm-12">
	<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
	<input type="hidden" name="token" value="{$_W['token']}" />
	</div>
	</form>
</div>

<script language='javascript'>
	function formcheck() {
		if ($("#advname").isEmpty()) {
			Tip.focus("advname", "请填写导航名称!");
			return false;
		}
		return true;
	}
</script>
{/if}
{template 'common/footer'}